package com.renjiyue.GUI;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

//TextField事件监听
public class GUIDome10 {
    public static void main(String[] args) {
        MyFrameTextField myFrameTextField = new MyFrameTextField();
        myFrameTextField.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }
}
class MyFrameTextField extends Frame{
    MyFrameTextField(){
        TextField textField = new TextField();
        add(textField);
        textField.addActionListener(new MyMonitor2());

        textField.setEchoChar('*');
        setVisible(true);
        pack();
    }
}
class MyMonitor2 implements ActionListener{
    @Override
    public void actionPerformed(ActionEvent e){
        TextField textField = (TextField)e.getSource();
        System.out.println(textField.getText());
        textField.setText("");
    }
}
